package com.zhiyi.app.controller;

import com.zhiyi.app.entity.User;
import com.zhiyi.app.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService service;

    @RequestMapping("/login")
    public String login(User user, HttpSession session){
        user=service.login(user);
        if (user!=null){
            session.setAttribute("user",user);
            return "index";
        }
        return "login";
    }
}
